package com.warrior.entity;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * 票务的entity
 * Created by Shawn on 2017/3/15.
 */
@Entity
@Table(name = "ticket", schema = "warrior")
public class TicketEntity {
    private String id;//记录门票id,用T-32位uuid表示
    private String ticketName;//记录门票名称
    private Double price;//记录门票价格字段
    private String activePlace;//记录门票的活动场地
    private Timestamp activeDate;//记录活动日期字段
    private Timestamp createdAt;//记录该条记录的创建时间
    private Timestamp updateAt;//记录该条记录的更新时间
    private Integer ticketStatus;//记录票务状态, 1表示在正常使用 -1表示过期
    private String createdBy;//记录该条记录的创建者
    private String updateBy;//记录该条记录由何人更新
    private ActivityEntity activityByActivityId;//记录活动id
    private String ticketUrl;//订票页面
    private String ticketPicPath;//票务图片

    @Id
    @Column(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "ticket_name")
    public String getTicketName() {
        return ticketName;
    }

    public void setTicketName(String ticketName) {
        this.ticketName = ticketName;
    }

    @Basic
    @Column(name = "price")
    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    @Basic
    @Column(name = "active_place")
    public String getActivePlace() {
        return activePlace;
    }

    public void setActivePlace(String activePlace) {
        this.activePlace = activePlace;
    }

    @Basic
    @Column(name = "active_date")
    public Timestamp getActiveDate() {
        return activeDate;
    }

    public void setActiveDate(Timestamp activeDate) {
        this.activeDate = activeDate;
    }

    @Basic
    @Column(name = "created_at")
    public Timestamp getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Timestamp createdAt) {
        this.createdAt = createdAt;
    }

    @Basic
    @Column(name = "update_at")
    public Timestamp getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Timestamp updateAt) {
        this.updateAt = updateAt;
    }

    @Basic
    @Column(name = "created_by")
    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @Basic
    @Column(name = "update_by")
    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    @Basic
    @Column(name = "ticket_status")
    public Integer getTicketStatus() {
        return ticketStatus;
    }

    public void setTicketStatus(Integer ticketStatus) {
        this.ticketStatus = ticketStatus;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TicketEntity that = (TicketEntity) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (ticketName != null ? !ticketName.equals(that.ticketName) : that.ticketName != null) return false;
        if (price != null ? !price.equals(that.price) : that.price != null) return false;
        if (activePlace != null ? !activePlace.equals(that.activePlace) : that.activePlace != null) return false;
        if (activeDate != null ? !activeDate.equals(that.activeDate) : that.activeDate != null) return false;
        if (createdAt != null ? !createdAt.equals(that.createdAt) : that.createdAt != null) return false;
        if (updateAt != null ? !updateAt.equals(that.updateAt) : that.updateAt != null) return false;
        if (createdBy != null ? !createdBy.equals(that.createdBy) : that.createdBy != null) return false;
        if (updateBy != null ? !updateBy.equals(that.updateBy) : that.updateBy != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (ticketName != null ? ticketName.hashCode() : 0);
        result = 31 * result + (price != null ? price.hashCode() : 0);
        result = 31 * result + (activePlace != null ? activePlace.hashCode() : 0);
        result = 31 * result + (activeDate != null ? activeDate.hashCode() : 0);
        result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
        result = 31 * result + (updateAt != null ? updateAt.hashCode() : 0);
        result = 31 * result + (createdBy != null ? createdBy.hashCode() : 0);
        result = 31 * result + (updateBy != null ? updateBy.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "activity_id", referencedColumnName = "id", nullable = false)
    public ActivityEntity getActivityByActivityId() {
        return activityByActivityId;
    }

    public void setActivityByActivityId(ActivityEntity activityByActivityId) {
        this.activityByActivityId = activityByActivityId;
    }

    @Basic
    @Column(name = "ticket_url")
    public String getTicketUrl() {
        return ticketUrl;
    }

    public void setTicketUrl(String ticketUrl) {
        this.ticketUrl = ticketUrl;
    }

    @Basic
    @Column(name = "ticket_pic_path")
    public String getTicketPicPath() {
        return ticketPicPath;
    }

    public void setTicketPicPath(String ticketPicPath) {
        this.ticketPicPath = ticketPicPath;
    }
}
